package com.bi.bitest.bao.tasks;

import android.os.AsyncTask;
import com.bi.bitest.bao.Client.ClientAPI;
import com.bi.bitest.bao.Constants;
import com.bi.bitest.bao.utils.EntityParseUtil;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created
 * Author:bi[FR]
 * Date:15-10-20
 */
public class DiscoverCategoryTask extends BaseTask {
    private TaskCallback callback;
   public  DiscoverCategoryTask(TaskCallback callback){
       super(callback);
    }

    @Override
    protected TaskResult doInBackground(String... params) {
        TaskResult ret=new TaskResult();
        //异步任务唯一标识每一个异步任务标志都不同
        ret.action= Constants.TASK_ACTION_DISCOVER_CATEGORIES;
        JSONObject jsonObject=ClientAPI.getDiscoverCategories();
       if(jsonObject!=null){
           try {
               ret.retCode=jsonObject.getInt("ret");
               ret.data= EntityParseUtil.parseDiscoverCategories(jsonObject);
           } catch (JSONException e) {
               e.printStackTrace();
           }

       }
        return ret;
    }


}
